home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / gutenprint / sequence.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-03-15  |  13.7 KB  |  390 lines

  1. /*
  2.  * "$Id: sequence.h,v 1.1 2004/09/17 18:38:01 rleigh Exp $"
  3.  *
  4.  *   libgimpprint sequence functions.
  5.  *
  6.  *   Copyright 2003 Roger Leigh (rleigh@debian.org)
  7.  *
  8.  *   This program is free software; you can redistribute it and/or modify it
  9.  *   under the terms of the GNU General Public License as published by the Free
  10.  *   Software Foundation; either version 2 of the License, or (at your option)
  11.  *   any later version.
  12.  *
  13.  *   This program is distributed in the hope that it will be useful, but
  14.  *   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  15.  *   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  16.  *   for more details.
  17.  *
  18.  *   You should have received a copy of the GNU General Public License
  19.  *   along with this program; if not, write to the Free Software
  20.  *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21.  */
  22.  
  23. /**
  24.  * @file gutenprint/sequence.h
  25.  * @brief Sequence functions.
  26.  */
  27.  
  28. /*
  29.  * This file must include only standard C header files.  The core code must
  30.  * compile on generic platforms that don't support glib, gimp, gimpprint, etc.
  31.  */
  32.  
  33. #ifndef GUTENPRINT_SEQUENCE_H
  34. #define GUTENPRINT_SEQUENCE_H
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39.  
  40.  
  41.   /**
  42.    * The sequence is a simple "vector of numbers" data structure.
  43.    *
  44.    * @defgroup sequence sequence
  45.    * @{
  46.    */
  47.  
  48. struct stp_sequence;
  49.   /** The sequence opaque data type. */
  50. typedef struct stp_sequence stp_sequence_t;
  51.  
  52.   /**
  53.    * Create a new sequence.
  54.    * @returns the newly created sequence.
  55.    */
  56. extern stp_sequence_t *stp_sequence_create(void);
  57.  
  58.   /**
  59.    * Destroy a sequence.
  60.    * It is an error to destroy the sequence more than once.
  61.    * @param sequence the sequence to destroy.
  62.    */
  63. extern void stp_sequence_destroy(stp_sequence_t *sequence);
  64.  
  65.   /**
  66.    * Copy an sequence.
  67.    * Both dest and source must be valid sequences previously created
  68.    * with stp_sequence_create().
  69.    * @param dest the destination sequence.
  70.    * @param source the source sequence.
  71.    */
  72. extern void stp_sequence_copy(stp_sequence_t *dest,
  73.                   const stp_sequence_t *source);
  74.  
  75.   /**
  76.    * Copy and allocate an sequence.
  77.    * A new sequence will be created, and then the contents of source will
  78.    * be copied into it.  The destination must not have been previously
  79.    * allocated with stp_sequence_create().
  80.    * @param sequence the source sequence.
  81.    * @returns the new copy of the sequence.
  82.    */
  83. extern stp_sequence_t *stp_sequence_create_copy(const stp_sequence_t *sequence);
  84.  
  85.   /**
  86.    * Set the lower and upper bounds.
  87.    * The lower and upper bounds set the minimum and maximum values
  88.    * that a point in the sequence may hold.
  89.    * @param sequence the sequence to work on.
  90.    * @param low the lower bound.
  91.    * @param high the upper bound.
  92.    * @returns 1 on success, or 0 if the lower bound is greater than
  93.    * the upper bound.
  94.    */
  95. extern int stp_sequence_set_bounds(stp_sequence_t *sequence,
  96.                    double low, double high);
  97.  
  98.   /**
  99.    * Get the lower and upper bounds.
  100.    * The values are stored in the variables pointed to by low and
  101.    * high.
  102.    * @param sequence the sequence to work on.
  103.    * @param low a pointer to a double to store the low bound in.
  104.    * @param high a pointer to a double to store the high bound in.
  105.    */
  106. extern void stp_sequence_get_bounds(const stp_sequence_t *sequence,
  107.                     double *low, double *high);
  108.  
  109.  
  110.   /**
  111.    * Get range of values stored in the sequence.
  112.    * The values are stored in the variables pointed to by low and
  113.    * high.
  114.    * @param sequence the sequence to work on.
  115.    * @param low a pointer to a double to store the low bound in.
  116.    * @param high a pointer to a double to store the high bound in.
  117.    */
  118. extern void stp_sequence_get_range(const stp_sequence_t *sequence,
  119.                    double *low, double *high);
  120.  
  121.   /**
  122.    * Set the sequence size.
  123.    * The size is the number of elements the sequence contains.  Note
  124.    * that resizing will destroy all data contained in the sequence.
  125.    * @param sequence the sequence to work on.
  126.    * @param size the size to set the sequence to.
  127.    * @returns 1 on success, 0 on failure.
  128.    */
  129. extern int stp_sequence_set_size(stp_sequence_t *sequence, size_t size);
  130.  
  131.   /**
  132.    * Get the sequence size.
  133.    * @returns the sequence size.
  134.    */
  135. extern size_t stp_sequence_get_size(const stp_sequence_t *sequence);
  136.  
  137.   /**
  138.    * Set the data in a sequence.
  139.    * @param sequence the sequence to set.
  140.    * @param count the number of elements in the data.
  141.    * @param data a pointer to the first member of a sequence
  142.    * containing the data to set.
  143.    * @returns 1 on success, 0 on failure.
  144.    */
  145. extern int stp_sequence_set_data(stp_sequence_t *sequence,
  146.                  size_t count,
  147.                  const double *data);
  148.  
  149.   /**
  150.    * Set the data in a subrange of a sequence.
  151.    * @param sequence the sequence to set.
  152.    * @param where the starting element in the sequence (indexed from
  153.    * 0).
  154.    * @param size the number of elements in the data.
  155.    * @param data a pointer to the first member of a sequence
  156.    * containing the data to set.
  157.    * @returns 1 on success, 0 on failure.
  158.    */
  159. extern int stp_sequence_set_subrange(stp_sequence_t *sequence,
  160.                      size_t where, size_t size,
  161.                      const double *data);
  162.  
  163.   /**
  164.    * Get the data in a sequence.
  165.    * @param sequence the sequence to get the data from.
  166.    * @param size the number of elements in the sequence are stored in
  167.    * the size_t pointed to.
  168.    * @param data a pointer to the first element of an sequence of doubles
  169.    * is stored in a pointer to double*.
  170.    * @code
  171.    * stp_sequence_t *sequence;
  172.    * size_t size;
  173.    * double *data;
  174.    * stp_sequence_get_data(sequence, &size, &data);
  175.    * @endcode
  176.    */
  177. extern void stp_sequence_get_data(const stp_sequence_t *sequence,
  178.                   size_t *size, const double **data);
  179.  
  180.   /**
  181.    * Set the data at a single point in a sequence.
  182.    * @param sequence the sequence to use.
  183.    * @param where the location (indexed from zero).
  184.    * @param data the datum to set.
  185.    * @returns 1 on success, 0 on failure.
  186.    */
  187. extern int stp_sequence_set_point(stp_sequence_t *sequence,
  188.                   size_t where, double data);
  189.  
  190.   /**
  191.    * Get the data at a single point in a sequence.
  192.    * @param sequence the sequence to use.
  193.    * @param where the location (indexed from zero).
  194.    * @param data the datum is stored in the double pointed to.
  195.    * @returns 1 on success, 0 on failure.
  196.    */
  197. extern int stp_sequence_get_point(const stp_sequence_t *sequence,
  198.                   size_t where, double *data);
  199.  
  200.  
  201.   /**
  202.    * Set the data in a sequence from float values.
  203.    * @param sequence the sequence to set.
  204.    * @param count the number of elements in the data.
  205.    * @param data a pointer to the first member of a sequence
  206.    * containing the data to set.
  207.    * @returns 1 on success, 0 on failure.
  208.    */
  209. extern int stp_sequence_set_float_data(stp_sequence_t *sequence,
  210.                        size_t count, const float *data);
  211.  
  212.   /**
  213.    * Set the data in a sequence from long values.
  214.    * @param sequence the sequence to set.
  215.    * @param count the number of elements in the data.
  216.    * @param data a pointer to the first member of a sequence
  217.    * containing the data to set.
  218.    * @returns 1 on success, 0 on failure.
  219.    */
  220. extern int stp_sequence_set_long_data(stp_sequence_t *sequence,
  221.                       size_t count, const long *data);
  222.  
  223.   /**
  224.    * Set the data in a sequence from unsigned long values.
  225.    * @param sequence the sequence to set.
  226.    * @param count the number of elements in the data.
  227.    * @param data a pointer to the first member of a sequence
  228.    * containing the data to set.
  229.    * @returns 1 on success, 0 on failure.
  230.    */
  231. extern int stp_sequence_set_ulong_data(stp_sequence_t *sequence,
  232.                        size_t count, const unsigned long *data);
  233.  
  234.   /**
  235.    * Set the data in a sequence from int values.
  236.    * @param sequence the sequence to set.
  237.    * @param count the number of elements in the data.
  238.    * @param data a pointer to the first member of a sequence
  239.    * containing the data to set.
  240.    * @returns 1 on success, 0 on failure.
  241.    */
  242. extern int stp_sequence_set_int_data(stp_sequence_t *sequence,
  243.                      size_t count, const int *data);
  244.  
  245.   /**
  246.    * Set the data in a sequence from unsigned int values.
  247.    * @param sequence the sequence to set.
  248.    * @param count the number of elements in the data.
  249.    * @param data a pointer to the first member of a sequence
  250.    * containing the data to set.
  251.    * @returns 1 on success, 0 on failure.
  252.    */
  253. extern int stp_sequence_set_uint_data(stp_sequence_t *sequence,
  254.                       size_t count, const unsigned int *data);
  255.  
  256.   /**
  257.    * Set the data in a sequence from short values.
  258.    * @param sequence the sequence to set.
  259.    * @param count the number of elements in the data.
  260.    * @param data a pointer to the first member of a sequence
  261.    * containing the data to set.
  262.    * @returns 1 on success, 0 on failure.
  263.    */
  264. extern int stp_sequence_set_short_data(stp_sequence_t *sequence,
  265.                        size_t count, const short *data);
  266.  
  267.   /**
  268.    * Set the data in a sequence from unsigned short values.
  269.    * @param sequence the sequence to set.
  270.    * @param count the number of elements in the data.
  271.    * @param data a pointer to the first member of a sequence
  272.    * containing the data to set.
  273.    * @returns 1 on success, 0 on failure.
  274.    */
  275. extern int stp_sequence_set_ushort_data(stp_sequence_t *sequence,
  276.                     size_t count, const unsigned short *data);
  277.  
  278.   /**
  279.    * Get the data in a sequence as float data.
  280.    * The pointer returned is owned by the curve, and is not guaranteed
  281.    * to be valid beyond the next non-const curve call;
  282.    * If the bounds of the curve exceed the limits of the data type,
  283.    * NULL is returned.
  284.    * @param sequence the sequence to get the data from.
  285.    * @param count the number of elements in the sequence are stored in
  286.    * the size_t pointed to.
  287.    * @returns a pointer to the first element of an sequence of floats
  288.    * is stored in a pointer to float*.
  289.    */
  290. extern const float *stp_sequence_get_float_data(const stp_sequence_t *sequence,
  291.                         size_t *count);
  292.  
  293.   /**
  294.    * Get the data in a sequence as long data.
  295.    * The pointer returned is owned by the curve, and is not guaranteed
  296.    * to be valid beyond the next non-const curve call;
  297.    * If the bounds of the curve exceed the limits of the data type,
  298.    * NULL is returned.
  299.    * @param sequence the sequence to get the data from.
  300.    * @param count the number of elements in the sequence are stored in
  301.    * the size_t pointed to.
  302.    * @returns a pointer to the first element of an sequence of longs
  303.    * is stored in a pointer to long*.
  304.    */
  305. extern const long *stp_sequence_get_long_data(const stp_sequence_t *sequence,
  306.                           size_t *count);
  307.  
  308.   /**
  309.    * Get the data in a sequence as unsigned long data.
  310.    * The pointer returned is owned by the curve, and is not guaranteed
  311.    * to be valid beyond the next non-const curve call;
  312.    * If the bounds of the curve exceed the limits of the data type,
  313.    * NULL is returned.
  314.    * @param sequence the sequence to get the data from.
  315.    * @param count the number of elements in the sequence are stored in
  316.    * the size_t pointed to.
  317.    * @returns a pointer to the first element of an sequence of
  318.    * unsigned longs is stored in a pointer to unsigned long*.
  319.    */
  320. extern const unsigned long *stp_sequence_get_ulong_data(const stp_sequence_t *sequence,
  321.                             size_t *count);
  322.  
  323.   /**
  324.    * Get the data in a sequence as int data.
  325.    * The pointer returned is owned by the curve, and is not guaranteed
  326.    * to be valid beyond the next non-const curve call;
  327.    * If the bounds of the curve exceed the limits of the data type,
  328.    * NULL is returned.
  329.    * @param sequence the sequence to get the data from.
  330.    * @param count the number of elements in the sequence are stored in
  331.    * the size_t pointed to.
  332.    * @returns a pointer to the first element of an sequence of ints
  333.    * is stored in a pointer to int*.
  334.    */
  335. extern const int *stp_sequence_get_int_data(const stp_sequence_t *sequence,
  336.                         size_t *count);
  337.  
  338.   /**
  339.    * Get the data in a sequence as unsigned int data.
  340.    * The pointer returned is owned by the curve, and is not guaranteed
  341.    * to be valid beyond the next non-const curve call;
  342.    * If the bounds of the curve exceed the limits of the data type,
  343.    * NULL is returned.
  344.    * @param sequence the sequence to get the data from.
  345.    * @param count the number of elements in the sequence are stored in
  346.    * the size_t pointed to.
  347.    * @returns a pointer to the first element of an sequence of
  348.    * unsigned ints is stored in a pointer to unsigned int*.
  349.    */
  350. extern const unsigned int *stp_sequence_get_uint_data(const stp_sequence_t *sequence,
  351.                               size_t *count);
  352.  
  353.   /**
  354.    * Get the data in a sequence as short data.
  355.    * The pointer returned is owned by the curve, and is not guaranteed
  356.    * to be valid beyond the next non-const curve call;
  357.    * If the bounds of the curve exceed the limits of the data type,
  358.    * NULL is returned.
  359.    * @param sequence the sequence to get the data from.
  360.    * @param count the number of elements in the sequence are stored in
  361.    * the size_t pointed to.
  362.    * @returns a pointer to the first element of an sequence of shorts
  363.    * is stored in a pointer to short*.
  364.    */
  365. extern const short *stp_sequence_get_short_data(const stp_sequence_t *sequence,
  366.                         size_t *count);
  367.  
  368.   /**
  369.    * Get the data in a sequence as unsigned short data.
  370.    * The pointer returned is owned by the curve, and is not guaranteed
  371.    * to be valid beyond the next non-const curve call;
  372.    * If the bounds of the curve exceed the limits of the data type,
  373.    * NULL is returned.
  374.    * @param sequence the sequence to get the data from.
  375.    * @param count the number of elements in the sequence are stored in
  376.    * the size_t pointed to.
  377.    * @returns a pointer to the first element of an sequence of
  378.    * unsigned shorts is stored in a pointer to unsigned short*.
  379.    */
  380. extern const unsigned short *stp_sequence_get_ushort_data(const stp_sequence_t *sequence,
  381.                               size_t *count);
  382.  
  383.   /** @} */
  384.  
  385. #ifdef __cplusplus
  386.   }
  387. #endif
  388.  
  389. #endif /* GUTENPRINT_SEQUENCE_H */
  390.